package com.slmn;

import java.util.Locale;

import com.slmn.visitor.gui.Cursor;
import com.slmn.visitor.gui.FormulaFrame;
import com.slmn.visitor.gui.HComposite;
import com.slmn.visitor.gui.Leaf;
import com.slmn.visitor.gui.VComposite;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Editor extends Application {

	public static void main(String[] args) {
		Editor.launch();
	}
	
	@Override
	public void start(Stage stage) throws Exception {
		Locale.setDefault(Locale.ENGLISH);
		BorderPane pane = new BorderPane();
		Leaf l0 = new Leaf("Leaf_00");
		Leaf l1 = new Leaf("Leaf_01");
		Leaf l2 = new Leaf("Leaf_02");
		Leaf l3 = new Leaf("Leaf_03");
		Leaf l4 = new Leaf("Leaf_04");
		Leaf l5 = new Leaf("Leaf_05");
		Leaf l6 = new Leaf("Leaf_06");
		Leaf l7 = new Leaf("Leaf_07");
		Leaf l8 = new Leaf("Leaf_08");
		HComposite hc1 = new HComposite();
		HComposite hc2 = new HComposite();
		HComposite hc3 = new HComposite();
		HComposite hc4 = new HComposite();
		HComposite hc5 = new HComposite();
		HComposite hc6 = new HComposite();
		VComposite root = new VComposite();
		VComposite vc1 = new VComposite();
		VComposite vc2 = new VComposite();
		hc1.addAll(l1, l2);
		hc2.addAll(l3, l4);
		hc3.addAll(l5, l6);
		hc6.addAll(l1);
		vc1.addAll(hc1, hc2, hc6);
		vc2.addAll(hc3);
		hc4.addAll(l0, vc1, vc2);
		hc5.addAll(l7,l8);
		root.addAll(hc4,hc5);
		FormulaFrame.add(root);
		
		 HBox hbox = new HBox(50);
		 hbox.setAlignment(Pos.CENTER);
		
	        VBox vbox1 = new VBox();
	        vbox1.setAlignment(Pos.BOTTOM_CENTER);
	        vbox1.setStyle("-fx-border-style: solid;"
	                + "-fx-border-width: 1;"
	                + "-fx-border-color: black");
	        
	        VBox vbox2 = new VBox(10);
	        vbox2.setAlignment(Pos.CENTER);
	        vbox2.setStyle("-fx-border-style: solid;"
	                + "-fx-border-width: 1;"
	                + "-fx-border-color: black");
	        
	        VBox vbox3 = new VBox(20);
	        vbox3.setAlignment(Pos.TOP_CENTER);
	        vbox3.setStyle("-fx-border-style: solid;"
	                + "-fx-border-width: 1;"
	                + "-fx-border-color: black");
		 for (int i = 0; i < 5; i++)
	        {
	            Button bt = new Button("Button " + (i+1));
	            Button bt2 = new Button("Button " + (i+1)); // unfortunately there´s no "clone" or "copy" method
	            Button bt3 = new Button("Button " + (i+1));
	            Pane hb = new Pane();
	            HBox hb1 = new HBox();
	            hb1.getChildren().add(bt2);
	            hb.getChildren().add(hb1);
	            vbox1.getChildren().add(bt);
	            vbox2.getChildren().add(hb);
	            vbox3.getChildren().add(bt3);
	        }
		 hbox.getChildren().addAll(vbox1, vbox2, vbox3);
		 
		VBox box = new VBox();
		pane.setStyle("-fx-border-color: red;");
		box.setStyle("-fx-border-color: blue;");
		box.getChildren().addAll(FormulaFrame.ff, hbox);
		Cursor.prompt.setHeight(100);
		box.setPrefSize(100, 100);
		//StackPane.setMargin(box, new Insets(24));
		//pane.getChildren().addAll(box, Cursor.prompt);
		pane.setCenter(box);
		pane.setRight(Cursor.prompt);
		Cursor.prompt.setX(200);
		
		Scene myScene = new Scene(pane, 800, 600);
		//myScene.getStylesheets().add(Demo.class.getResource("/dasgui.css").toExternalForm());
		stage.setScene(myScene);
		stage.show();
	}

}

